package com.tea.funct.service.impl;

import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaDetails;
import com.tea.funct.mapper.TeaDetailsMapper;
import com.tea.funct.service.ITeaDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品明细Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaDetailsServiceImpl implements ITeaDetailsService {
    @Autowired
    private TeaDetailsMapper teaDetailsMapper;

    /**
     * 查询产品明细
     *
     * @param id 产品明细主键
     * @return 产品明细
     */
    @Override
    public TeaDetails selectTeaDetailsById(Long id) {
        return teaDetailsMapper.selectTeaDetailsById(id);
    }

    /**
     * 查询产品明细列表
     *
     * @param teaDetails 产品明细
     * @return 产品明细
     */
    @Override
    public List<TeaDetails> selectTeaDetailsList(TeaDetails teaDetails) {
        return teaDetailsMapper.selectTeaDetailsList(teaDetails);
    }

    /**
     * 新增产品明细
     *
     * @param teaDetails 产品明细
     * @return 结果
     */
    @Override
    public int insertTeaDetails(TeaDetails teaDetails) {
        teaDetails.setCreateTime(DateUtils.getNowDate());
        return teaDetailsMapper.insertTeaDetails(teaDetails);
    }

    /**
     * 修改产品明细
     *
     * @param teaDetails 产品明细
     * @return 结果
     */
    @Override
    public int updateTeaDetails(TeaDetails teaDetails) {
        teaDetails.setUpdateTime(DateUtils.getNowDate());
        return teaDetailsMapper.updateTeaDetails(teaDetails);
    }

    /**
     * 批量删除产品明细
     *
     * @param ids 需要删除的产品明细主键
     * @return 结果
     */
    @Override
    public int deleteTeaDetailsByIds(Long[] ids) {
        return teaDetailsMapper.deleteTeaDetailsByIds(ids);
    }

    /**
     * 删除产品明细信息
     *
     * @param id 产品明细主键
     * @return 结果
     */
    @Override
    public int deleteTeaDetailsById(Long id) {
        return teaDetailsMapper.deleteTeaDetailsById(id);
    }

    @Override
    public Integer insertTeaDetailsList(List<TeaDetails> list) {
        return teaDetailsMapper.insertTeaDetailsList(list);
    }

    @Override
    public List<TeaDetails> selectTeaDetailsListByUserId(Long userId) {
        return teaDetailsMapper.selectTeaDetailsListByUserId(userId);
    }

    @Override
    public List<Long> selectTeaDetailsListByPruductsAndUserId(List<Long> ids, Long userId) {
        return teaDetailsMapper.selectTeaDetailsListByPruductsAndUserId(ids, userId);
    }
}
